import os
from pydantic_settings import BaseSettings
from typing import List


class Config(BaseSettings):
    # 调试模式
    APP_DEBUG: bool = True
    DEBUG_LEVEL: str = "INFO"
    DEVELOP_HOST: str = "127.0.0.1"
    DEVELOP_PORT: int = 8000
    # 项目信息
    VERSION: str = "1.0"
    PROJECT_NAME: str = "IIoT Gateway"
    DESCRIPTION: str = '<a href="/redoc" target="_blank">redoc</a>'
    # 静态资源目录
    STATIC_DIR: str = os.path.join(os.getcwd(), "template")
    SWAGGER_DIR: str = STATIC_DIR + "/swagger"
    # 跨域请求
    CORS_ORIGINS: List = ["*"]
    CORS_ALLOW_CREDENTIALS: bool = True
    CORS_ALLOW_METHODS: List = ["*"]
    CORS_ALLOW_HEADERS: List = ["*"]
    # SQLite
    SQLITE_URL: str = f"sqlite:///{os.getcwd()}/data.db"
    # PLC可解析功能码列表
    FUNC_10: list[str] = ["M", "D"]
    FUNC_16: list[str] = ["X", "Y"]
    # PLC每次通讯读取最大长度限制
    MAX_PLC_READ_LEN: int = 50
    SWAGGER_UI_OAUTH2_REDIRECT_URL: str = "/api/token"


settings = Config()
